package nl.stroep.classbuilder.cb 
{
	import nl.stroep.classbuilder.cb.interfaces.ICbObject;
	import nl.stroep.classbuilder.cb.interfaces.ICbWrapper;
	import nl.stroep.classbuilder.definitions.Chars;
	
	/**
	 * Defines a setter definition, which is a method that appears in the public interface as a property.
	 * @author Mark Knol - Stroep.nl - 2010 (c)
	 */
	public class CbSetMethod implements ICbWrapper
	{
		private var cbFunction:CbMethod;
		
		private var _name:String;
		private var _type:String;
		private var _defaultValue:String;
		
		private var parameters:Vector.<CbParameter>;
		
		
		public function CbSetMethod(name:String, type:String = "void", defaultValue:String = null ) 
		{
			cbFunction = new CbMethod(name);
			
			cbFunction.isSetter = true;
			
			parameters = new Vector.<CbParameter>()
			parameters.push (new CbParameter("value", type));
			
			this._name = name;
			this._type = type;
			this._defaultValue = defaultValue;
		}
		
		public function toString():String
		{
			cbFunction.name = this._name;
			cbFunction.type = this._type;
			cbFunction.defaultValue =  "_" + this._name + Chars.EQUAL + "value;" + (this._defaultValue ? Chars.NEWLINE + this._defaultValue : Chars.EMPTY);
			cbFunction.parameters = parameters;
			
			return cbFunction.toString()
		}
		
		public function get name():String { return _name; }
		
		public function set name(value:String):void 
		{
			_name = value;
		}
		
		public function get type():String { return _type; }
		
		public function set type(value:String):void 
		{
			_type = value;
		}
		
		public function get defaultValue():String { return _defaultValue; }
		
		public function set defaultValue(value:String):void 
		{
			_defaultValue = value;
		}
		
		
	}

}